package com.cn.kehong.controller;

import com.cn.kehong.api.IProductDianciPeriodService;
import com.cn.kehong.api.IProductSaojiePeriodService;
import com.cn.kehong.domain.ProductDianciPeriod;
import com.cn.kehong.domain.ProductSaojieJob;
import com.cn.kehong.domain.ProductSaojiePeriod;
import com.cn.kehong.utils.CommonUtil;
import com.cn.kehong.utils.JsonResponse;
import com.cn.kehong.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/dianci")
public class ProductDianciPeriodController {

    @Autowired
    private IProductDianciPeriodService productDianciPeriodService;


    @RequestMapping("/getProductDianciPeriodList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProductDianciPeriod>> getProductDianciPeriodList(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<ProductDianciPeriod>> response = new JsonResponse<List<ProductDianciPeriod>>();
        List<ProductDianciPeriod> lists = productDianciPeriodService.getProductDianciPeriodList(queryForm);
        response.setResult(lists);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/getProductDianciPeriodListByStatus/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProductDianciPeriod>> getProductDianciPeriodListByStatus(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<ProductDianciPeriod>> response = new JsonResponse<List<ProductDianciPeriod>>();
        List<ProductDianciPeriod> lists = productDianciPeriodService.getProductDianciPeriodListByStatus(queryForm);
        response.setResult(lists);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/updateProductDianciToFenji/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateProductDianciToFenji(ProductDianciPeriod productDianciPeriod, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = productDianciPeriodService.updateProductDianciToFenji(productDianciPeriod);
        return CommonUtil.getResponseData(response,result);
    }

    @RequestMapping("/updateEndProductDianciPeriod/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateEndProductDianciPeriod(ProductDianciPeriod productDianciPeriod, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = productDianciPeriodService.updateEndProductDianciPeriod(productDianciPeriod);
        return CommonUtil.getResponseData(response,result);
    }

}
